home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AEWIN100.ARJ / BOX.CC < prev    next >
C/C++ Source or Header  |  1990-12-26  |  2KB  |  107 lines

  1. /**********************************************************************
  2.  *  
  3.  *  NAME:           box.cpp
  4.  *  
  5.  *  DESCRIPTION:    box/unbox a window
  6.  *  
  7.  *  copyright (c) 1990 J. Alan Eldridge
  8.  * 
  9.  *  M O D I F I C A T I O N   H I S T O R Y
  10.  *
  11.  *  when        who                 what
  12.  *  -------------------------------------------------------------------
  13.  *  08/14/90    J. Alan Eldridge    created
  14.  *  
  15.  *  11/30/90    JAE                 taken from UWin++ 1.00
  16.  *  
  17.  *********************************************************************/
  18.  
  19. #include    "w.h"
  20.  
  21. void
  22. basewin::box(
  23.     int yul,
  24.     int xul,
  25.     int ylr,
  26.     int xlr,
  27.     int vChr,
  28.     int hChr,
  29.     int fillFlg,
  30.     int fillChr)
  31. {    
  32.     uchar   corners[4];
  33.     uchar   vert, horz;
  34.         
  35.     int rows = ylr - yul + 1;
  36.     int cols = xlr - xul + 1;
  37.        
  38.     if (rows < 2 || cols < 2) 
  39.         return;
  40.     
  41.     if ((hChr == boxLine1 || hChr == boxLine2)
  42.         && (vChr == boxLine1 || vChr == boxLine2)) {
  43.         int vsel = vChr == boxLine1 ? SINGLE_LINE : DOUBLE_LINE;
  44.         int hsel = hChr == boxLine1 ? SINGLE_LINE : DOUBLE_LINE;
  45.  
  46.         vert = linechar(vsel, LINE_VERT);
  47.         horz = linechar(hsel, LINE_HORZ);
  48.         
  49.         for (int i = 0; i < 4; i++)
  50.             corners[i] = cornerchar(i, vsel, hsel);
  51.     } else {
  52.         vert = vChr;
  53.         horz = hChr;
  54.         
  55.         for (int i = 0; i < 4; i++)
  56.             corners[i] = vert;
  57.     }
  58.  
  59.     clrline(yul, xul + 1, cols - 2, horz, att);
  60.     clrline(ylr, xul + 1, cols - 2, horz, att);
  61.     
  62.     for (int y = yul + 1; y < ylr; y++) {
  63.         vidptr(y, xul)->put(vert, att);
  64.         vidptr(y, xlr)->put(vert, att);
  65.         if (fillFlg)
  66.             clrline(y, xul + 1, xlr - 1, fillChr, att);
  67.     }
  68.     
  69.     vidptr(yul, xul)->put(corners[0], att);
  70.     vidptr(yul, xlr)->put(corners[1], att);
  71.     vidptr(ylr, xlr)->put(corners[2], att);
  72.     vidptr(ylr, xul)->put(corners[3], att);
  73. }
  74.  
  75. void
  76. basewin::frame(
  77.     int vchr,
  78.     int hchr,
  79.     int fillflg,
  80.     int fillchr)
  81. {
  82.     fullport();
  83.     box(vchr, hchr, fillflg, fillchr);
  84.     fFrame = TRUE;
  85.     yUL++; xUL++;
  86.     yLR--; xLR--;
  87.     setpos(0,0);
  88. }
  89.         
  90. void
  91. basewin::closebox()
  92. {
  93.     int y, x;
  94.     getpos(y, x);
  95.  
  96.     viewport    port = getport();
  97.     fullport();
  98.  
  99.     setpos(0, 2);
  100.     put("[\xFE]");
  101.  
  102.     setport(port);
  103.     setpos(y, x);
  104.     fCloseBox = TRUE;
  105. }
  106.  
  107.